package cn.yiueil;

public class BookShelfIterator implements Iterator<Book> {
    private int index = 0;
    private final BookShelf bookShelf;

    public BookShelfIterator(BookShelf bookShelf) {
        this.bookShelf = bookShelf;
    }

    @Override
    public boolean hasNext() {
        return index < bookShelf.getLength();
    }

    @Override
    public Book next() {
        return bookShelf.get(index++);
    }
}
